Fix #53: imread doesn't close the file it opens.
Removed useless magicbuf parameter.
Safer stream opening.

Also, imwrite shouldn't close what it didn't open.
Merge pull request #55 from lucasb-eyer/master

Fix #53 and some