added tempfile support to remove need for user permissions