better handling of deleting temp files

moved deletion of temporary files to finally clause
so they are always deleted even if it fails
redirect when done with phot

Whether we are successful or not the session variables and temporary
files are no longer valid so we should move back to the beginning
made redirects more sensible