Filesize doesn't seem to work over ssh, fixed

After using the library in a project the client reported that downloaded files are all truncated to 2kb, after some digging it seems that file_size doesn't work correctly over ssh, so I have updated the code to loop over the content of the file and then save it, the buffer size can be changed as a parameter.

Regards.