Bug in the creation/cleanup of tmp files for stale file detection.

On some systems it was possible that the "/tmp/lua_??????" would not
get cleaned up. After a few hours of this you could be left with a
dirty tmp folder and a full disk.

This changes two things:

 1. in the manual copy path of FileRename, make sure the file handles
 are always closed and make sure the original is always removed.

 2. anywhere os.tmpname is used, always delete the file after, if it's
 been moved already then this has no effect.