Fix function write for big files on windows 8