Add support for tempdir

Saving temporary files inplace messes with file watchers.