Detect 403 or 404 in page.tpl.php
If my assumption is correct, then you are looking for the way to handle 404 and 403 pages.

If that is the case,


  Goto configuration->Site information, there you can specify your own page for handling 404 or 
  403 pages.


For that particular page, you can write tpl file like node--type--nid.tpl.php