     private func createConfigTemplate(file: String) -> Void {
         let jsonString = Utils.toJSON(baseConfigTemplate)
         if (jsonString != nil) {
-            do {
-                try jsonString!.writeToFile(file, atomically: true, encoding: NSUTF8StringEncoding)
+            if (saveString(jsonString!, file: file)) {
                 Utils.debug("JSON template created at \"\(file)\"")
-            }
-            catch {
-                print("Error: writing to \(file)")
             }
         }
     }

        let configTemplateFile = getOption(args, option: "-config_template")
        if (configTemplateFile != nil) {
            createConfigTemplate(configTemplateFile!)
            exit(0)
        }
        

        else {
            return image.saveTo(file)
        }
    }
    
    func saveString(data:String, file: String) -> Bool
    {
        do {
            try data.writeToFile(file, atomically: true, encoding: NSUTF8StringEncoding)
        }
        catch {
            print("Error: writing to \(file)")
            exit(-1)
        }
        return true
    }
    
    private func writeImageStringArray(stringArray: Dictionary<String, AnyObject>, type: LangType) -> String {
