Remove temporary file at safeWriteToFile()

Partial fix of this https://github.com/minetest/minetest/issues/1086.