         memoryCache.setObject(image, forKey: identifier, cost: Int(image.size.width * image.size.height))
     }
     
+    fileprivate func createImage(data: Data) -> UIImage? {
+        guard let source = CGImageSourceCreateWithData(data as CFData, nil), CGImageSourceGetCount(source) > 0 else {
+            return nil
+        }
+        let options = [kCGImageSourceShouldCache as String: NSNumber(value: true)] as CFDictionary
+        guard let cgImage = CGImageSourceCreateImageAtIndex(source, 0, options) else {
+            return nil
+        }
+        let image = UIImage(cgImage: cgImage)
+        return image
+    }
+    
+    fileprivate func createImage(fileURL: URL) -> UIImage? {
+        guard let source = CGImageSourceCreateWithURL(fileURL as CFURL, nil), CGImageSourceGetCount(source) > 0 else {
+            return nil
+        }
+        let options = [kCGImageSourceShouldCache as String: NSNumber(value: true)] as CFDictionary
+        guard let cgImage = CGImageSourceCreateImageAtIndex(source, 0, options) else {
+            return nil
+        }
+        let image = UIImage(cgImage: cgImage)
+        return image
+    }
+    
     public func permanentlyCachedImage(withURL url: URL) -> UIImage? {
         if let memoryCachedImage = memoryCachedImage(withURL: url) {
             return memoryCachedImage

        guard let data = sessionCachedData(withURL: url) else {
            return nil
        }
        guard let image = UIImage(data: data) else {
            return nil
        }
        addToMemoryCache(image, url: url)

            defer {
                completion()
            }
            guard let image = self.createImage(data: data) else {
                return
            }
            self.addToMemoryCache(image, url: url)
