Changed the handling of temp files

Added code that creates a temp directory, and creates unique filenames
using the File.createTempFile in that directory. If the temp directory
cannot be created for any reason, it tries to use the system defined
temporary directory (usually "/tmp" in unix and "C:\\WINNT\\TEMP" in
windows).