close the temp file handle returned by mkstemp

Otherwise we are leaking open file handles and run out of them at some point. This should fix #203.