Use Dir.tmpdir instead of hardcoded /tmp

Closes #492