Fixed implementation of copy to work with large files.