refactor tiffgray.py