                             }
                             
                             do {
-                                try imageData.write(to: asset.localTemporaryPath!, options: [.atomic])
+                                try write(data: imageData, to: asset.localTemporaryPath!)
                                 completion(nil)
                             } catch {
                                 completion(error)

        }
    }
    
    private func exportAVAsset(with asset: DKAsset, progress: @escaping (Double) -> Void, completion: @escaping (Error?) -> Void) {
        let options = PHVideoRequestOptions()
        options.deliveryMode = .mediumQualityFormat
        options.progressHandler = { (p, _, _, _) in
            progress(p)
        }
        
        asset.fetchAVAsset(options: options) { (avAsset, info) in
            if let avAsset = avAsset {
                if let avURLAsset = avAsset as? AVURLAsset {
                    asset.fileName = avURLAsset.url.lastPathComponent

                        }
                    }
                })
                self.currentAssetInRequesting = asset
                
                semaphore.wait()
            }
        } else {
            DKImageAssetExporter.ioQueue.async {
                if self.operations[requestID] == nil {
                    return completion(self.makeCancelledError())
                }
                
                do {
                    try write(data: UIImageJPEGRepresentation(asset.image!, 0.9)!, to: asset.localTemporaryPath!)
                    completion(nil)
                } catch {
                    completion(error)
