fix write for very large files.
Merge pull request #15 from tyro89/master

fix write for very large files.