for security update

change mode after creating key file
tmporary filename bug fix