how can i define a maintenance template within a custom module?
drupal_get_http_header() should be treated as deprecated.

See https://www.drupal.org/node/1969270#comment-7609337

I think your approach is good, but for a little more coverage of 404/403 pages we came up with a more extendable approach, also theres a bit more room for customization in the backend within the modules settings page.

We did this by using the customerror module in conjunction with a theme function and a few overriding template files.

https://www.drupal.org/project/customerror

After installing, add this to your template.php file's theme_preprocess_page function. Example;

function YOURTHEME_preprocess_page(&amp;$variables) {

  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) &amp;&amp; $alias_parts[0] == 'customerror') {
    if ($alias_parts[1] == '403') {
      $variables['theme_hook_suggestions'][] = 'page__forbidden';
    }
    if ($alias_parts[1] == '404') {
      $variables['theme_hook_suggestions'][] = 'page__not_found';
    }
  }

  &lt;other code goes here&gt;

}


Then in your templates folder add your custom templates (just like your page.tpl.php file);


page--forbidden.tpl.php
page--not-found.tpl.php


Clear your cache, hit one of those pages (you can test them by going to);


[yoursite]/customerror/403
[yoursite]/customerror/404


As for your maintenance page, all you need to do is create a 
maintenance-page.tpl.php file and toss that in your templates folder.