Save image from URL to a field from a custom module
Hope this will help  you,

In Drupal 7,  for your requirement I made some changes.


As system_retrieve_file function will download a file from a remote source, copy it from temp to a specified destination and optionally save it to the file_managed table if you want it to be managed.

$node = new stdClass();
$node->type = "node_type";
node_object_prepare($node);
$node->title    =  'your title here';
$node->language = LANGUAGE_NONE;
$node->uid = 1;
$url = 'https://ssl.gstatic.com/gb/images/k1_a31af7ac.png';
//I have used picture folder to store images using image field settings
$file_info = system_retrieve_file($url, 'public://pictures/', TRUE);
if($file_info->fid){
    $node->field_image[LANGUAGE_NONE]['0']['fid'] = $file_info->fid;//assign fid
}
$node->field_test_field[LANGUAGE_NONE]['0']['value'] = 'test';//other fields 
if($node = node_submit($node)) {
    node_save($node);
    drupal_set_message('submitted successfully');
}



Make changes as per your requirement.