How to style a programmatically created page with a template?
In this case your page is a form, so you need to create a form template this way:

Implement hook_form_alter() in a module or template.php and set the form's #theme property:

function _mymodule_filedownload_form($form, &amp;$form_state, $mycustomfile)
{
    ...
    $form['#theme'] = array('mymodule_filedownload_form');
    ...

}


Then implement new theme:

/**
 * Implements hook_theme().
 */
function hook_theme($existing, $type, $theme, $path){
  $path = drupal_get_path('module', 'mymodule');
  return array(
    'mymodule_filedownload_form' =&gt; array(
      'render element' =&gt; 'form',
      'template' =&gt; 'form--mymodule_filedownload_form',
      'path' =&gt; $path . '/templates',
    ),
  );
}


And then add form--mymodule_filedownload_form.php template with follow code to render complete form (you can render it also by components):

&lt;?php print drupal_render_children($form) ?&gt;