diff --git a/includes/file.inc b/includes/file.inc
index b7a1204..ec6c137 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -1911,7 +1911,7 @@ function file_download() {
       $function = $module . '_file_download';
       $result = $function($uri);
       if ($result == -1) {
-        return drupal_access_denied();
+        return MENU_ACCESS_DENIED;
       }
       if (isset($result) && is_array($result)) {
         $headers = array_merge($headers, $result);
@@ -1921,7 +1921,7 @@ function file_download() {
       file_transfer($uri, $headers);
     }
   }
-  return drupal_not_found();
+  return MENU_NOT_FOUND;
 }
 
 
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 60a9ca4..81ce19f 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -486,7 +486,7 @@ function comment_permalink($cid) {
     // Return the node view, this will show the correct comment in context.
     return menu_execute_active_handler('node/' . $node->nid, FALSE);
   }
-  drupal_not_found();
+  return MENU_NOT_FOUND;
 }
 
 /**
diff --git a/modules/image/image.module b/modules/image/image.module
index 5caf282..548dcb7 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -661,12 +661,12 @@ function image_style_deliver($style, $scheme) {
   // control access to the file.
   if ($scheme == 'private') {
     if (file_exists($derivative_uri)) {
-      file_download($scheme, file_uri_target($derivative_uri));
+      return file_download($scheme, file_uri_target($derivative_uri));
     }
     else {
       $headers = module_invoke_all('file_download', $image_uri);
       if (in_array(-1, $headers) || empty($headers)) {
-        return drupal_access_denied();
+        return MENU_ACCESS_DENIED;
       }
       if (count($headers)) {
         foreach ($headers as $name => $value) {
diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test
index dc12b1b..e68aa13 100644
--- a/modules/simpletest/tests/file.test
+++ b/modules/simpletest/tests/file.test
@@ -2244,10 +2244,24 @@ class FileDownloadTest extends FileTestCase {
     $this->drupalHead($url);
     $this->assertResponse(403, t('Correctly denied access to a file when file_test sets the header to -1.'));
 
+    // Test that 403 page is cached and gzip compressed.
+    variable_set('cache', 1);
+    $this->drupalGet($url, array(), array('Accept-Encoding: gzip,deflate'));
+    $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8)));
+    $this->assertRaw('</html>', t('Page was gzip compressed.'));
+    variable_set('cache', 0);
+
     // Try non-existent file.
     $url = file_create_url('private://' . $this->randomName());
     $this->drupalHead($url);
     $this->assertResponse(404, t('Correctly returned 404 response for a non-existent file.'));
+
+    // Test that 404 page is cached and gzip compressed.
+    variable_set('cache', 1);
+    $this->drupalGet($url, array(), array('Accept-Encoding: gzip,deflate'));
+    $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8)));
+    $this->assertRaw('</html>', t('Page was gzip compressed.'));
+    variable_set('cache', 0);
   }
 
   /**
