This will minimize the amount of errors we'll get.
See the following for input on how it could be done: http://stackoverflow.com/a/6409531
Some implementations, like WP already have support for this:
$response = wp_safe_remote_get($url, array(
'stream' => TRUE,
'filename' => $file,
'timeout' => 60
No php timeout when downloading files(only socket timeout).
All H5P plugins should stream the file to the filesystem instead of relying on fitting it into the memory before writing to disk.