Ensure that generated configuration files are not deleted before uploading

Recent refactoring (805e857) can lead to situations where the Tempfile
is garbage collected and thus the file deleted before uploading to the
VM. We have to make sure that the Tempfile stays in the scope long
enough.
Merge pull request #29 from tmatilai/tempfile

The generated tempfile is sometimes deleted before uploading