Fix bug related to using the same tempfile for input and output.
Merge pull request #24 from localmed/tempfilebug

Fix bug related to using the same tempfile for input and output.