Fix opening 358MPix Tiff

With following changes DT can now open 358MPix Tiff file produced by Hugin:
```
[tiff_open] 26770x13385 16bpp, 4 samples per pixel.
```
I also tested it on all combinations of TIFF's DT can produce - no regressions.
Also some generic cleanup.

TODO: BigTIFF support.