diff --git a/core/includes/file.inc b/core/includes/file.inc
index c4356a9..57d0741 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -2046,7 +2046,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);
@@ -2057,7 +2057,7 @@ function file_download() {
     }
     return drupal_access_denied();
   }
-  return drupal_not_found();
+  return MENU_NOT_FOUND;
 }
 
 
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 0302913..ba85887 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -508,7 +508,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/core/modules/image/image.module b/core/modules/image/image.module
index 9e13c85..a851f43 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -686,12 +686,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/core/modules/system/tests/file.test b/core/modules/system/tests/file.test
index 173d05a..0c68537 100644
--- a/core/modules/system/tests/file.test
+++ b/core/modules/system/tests/file.test
@@ -2412,10 +2412,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);
   }
 
   /**
