Fixed open file descriptors

Fixed issue #12. All temp files file descriptors were
never being closed, leading to too many open files.
Merge pull request #13 from mpharrigan/master

Fixed open file descriptors