Fix resource leak from the method SaveToFile and added a asynchronously one
#1046
+151
−23
SaveToFile and added a asynchronously one
#1046