When you buy a domain with lots of existing links, but for some reason you can't or don't want to recreate the previous pages and content, what would be the best way to keep and redirect to the homepage the power of all those existing links?

Right now i have a .htaccess where i've set the 404 page to be 404.php and in 404.php i have

Code:
<?
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: h**p://" . $_SERVER['HTTP_HOST'] ); //this just takes the root domain name and points there
?>
so basically i send them all to 404 page and there 301 redirect them to the homepage.
Is that the best way? Since it goes through a 404 redirect, does that kills the link juice?
Matt Cuts says that 301 redirect keep the most of it, but since we have and 404 page involved here i decided to ask