refactor jpeg reader to close fd after read - refs #1783
fix memory leak when reading invalid tiff - refs #1783