diff --git a/bob/pad/face/database/batl.py b/bob/pad/face/database/batl.py
index fe44953db869c3e5839450cf04762407afa6ea64..98db4eecddce027933b8b29f49099f693f2d306f 100644
--- a/bob/pad/face/database/batl.py
+++ b/bob/pad/face/database/batl.py
@@ -270,7 +270,10 @@ class BatlPadDatabase(PadDatabase):
 
             if self.annotations_temp_dir: # if directory is not an empty string
 
-                with open(file_path, 'w') as json_file:
+                if not os.path.exists( os.path.split(file_path)[0] ):
+                    os.makedirs( os.path.split(file_path)[0] )
+
+                with open(file_path, 'w+') as json_file:
 
                     json_file.write(json.dumps(annotations))