Fixed libimobiledevice _afc_file_write wrapper to loop until all bytes are written.

_afc_file_write is used by the idevice interface to copy files to the
idevice. This fix has been successfully tested by round tripping a 500
MB file from the PC to the device and back again, and checking that the
before and after files are identical.