Image Upload in a Custom Module
If you don't mind my saying you're doing this the hard way. Drupal has a managed_file element type that handles most of this logic for you:

function mymodule_custom_content_block_form($form, &amp;$form_state) {
  $form['custom_content_block_image'] = array(
    '#type' =&gt; 'managed_file',
    '#name' =&gt; 'custom_content_block_image',
    '#title' =&gt; t('Block image'),
    '#size' =&gt; 40,
    '#description' =&gt; t("Image should be less than 400 pixels wide and in JPG format."),
    '#upload_location' =&gt; 'public://'
  ); 

  return $form; 
}

function mymodule_custom_content_block_form_submit($form, &amp;$form_state) {
  if (isset($form_state['values']['custom_content_block_image'])) {
    $file = file_load($form_state['values']['custom_content_block_image']);

    $file-&gt;status = FILE_STATUS_PERMANENT;

    file_save($file);
  }
}