Use random filenames for tmp files

Fixes #1