diff --git a/src/ocrfeeder/feeder/ocrEngines.py b/src/ocrfeeder/feeder/ocrEngines.py
index b8636d0..b141960 100644
--- a/src/ocrfeeder/feeder/ocrEngines.py
+++ b/src/ocrfeeder/feeder/ocrEngines.py
@@ -49,7 +49,7 @@ class Engine:
         if image == None:
             self.image_path = None
         else:
-            self.image_path = self.setImage(image)
+            self.setImage(image)
         self.image_format = image_format
         self.failure_string = failure_string
         self.language_argument = language_argument
@@ -58,22 +58,25 @@ class Engine:
         self.__color_information = None
         self.setLanguage('')
 
-    def setImage(self, image):
-        image_file = tempfile.mkstemp(dir = self.temporary_folder,
-                                      suffix = '.' + self.image_format.lower())[1]
-        image = image.convert('L')
+    def setImage(self, new_image):
+        image = new_image.convert('L')
+        dir = self.temporary_folder
+        suffix = '.' + self.image_format.lower()
+        tmp = tempfile.NamedTemporaryFile(dir = dir, suffix = suffix, delete = False)
+        tmp_path = tmp.name
         try:
-            image.save(image_file, format = self.image_format)
+            image.save(tmp, format = self.image_format)
         except KeyError:
-            image.save(image_file)
-        self.image_path = image_file
+            image.save(tmp)
+        tmp.close()
+        self.image_path = tmp_path
+        return
 
     def read(self):
         parsed_arguments = self.arguments.replace(IMAGE_ARGUMENT, self.image_path)
-        file_name = None
         if self.arguments.find(FILE_ARGUMENT) != -1:
-            file_name = tempfile.mkstemp(dir = self.temporary_folder)[1]
-            parsed_arguments = parsed_arguments.replace(FILE_ARGUMENT, file_name)
+            tmp = tempfile.NamedTemporaryFile(dir = self.temporary_folder, delete = False)
+            parsed_arguments = parsed_arguments.replace(FILE_ARGUMENT, tmp.name)
 
         if self._favorite_language:
             if self.languages:
