multipage tiff support

I redid this fix and merged your changes, following the contribution and testing guidelines, to see if it passes travis.