Tests for #526
close the fd, if possible. Fixes #526
Renamed variables from reused single letter confusing names to something halfway descriptive
Removed warning import, stray im=None, and moved os import to top
Merge pull request #580 from wiredfool/libtiff-fd-leak

Fixes libtiff leaking open files