Rewrite of tiff reader code to support loading of grayscale images.

Adds handling of images with 1 sample per pixel which usally dont have
any planar config set. This fixes bug #9747 and #9699.