Add buffersize, replication option, give option to append to exist file or not, fix bugs in copyToLocal