Fixes #308
Merge pull request #309 from maebert/tmpfile-fix

Fixes #308