Copy the error.php file from your-site/templates/system to your template main directory.
Then just open the error.php file from your Joomla template and edit it.
If you want to redirect to a sitemap on your site for example use this code at the top of the error.php file before everything in the file write:
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
header('Location: http://www.yoursite.com/sitemap');
exit;
}
?>