use temp module

this makes use of a temp module to automatically generate a temporary directory and remove any files created when the process terminates