tiff io: avoid over-allocation + add more tests