Close files correctly in imread. Fixes #53.
Removed unnecessary magicbuf.