prevent unexpected permission changing

just save file as original permission.

by the way, could you tell me why you create temporary file and replace original file instead of just write converted data to original file?