Fixes libtiff leaking open files

Fixes #526.