Write file path fix

tested on ubuntu and windows 7, seems that downloading issue and write file works on both platform now.