fixed issue with tmp file  and symlinking

tmpfile now accounts for path having filename in it 
added missing 'else' which made it try to link x2
hopefully fixes #6576