fix bugs around create temporary file.