     println("\t-help\t\t\t\tPrint this help message")
     exit(1)
 } else {
-    var fileExtension : String!
-    var imageType : String!
+    var fileExtension = "png"
+    var imageType = kUTTypePNG
     
-    if let type = userDefaults.stringForKey("t") {
-        fileExtension = type
+    if var type = userDefaults.stringForKey("t") {
         
         switch type {
         case "jpg", "jpeg":

        if let image = generateQRImageFromString(input, errorCorrection, size) {
            
            if let URL = NSURL(fileURLWithPath:path) {
                let destination : CGImageDestinationRef = CGImageDestinationCreateWithURL(URL, imageType, 1, nil)
                CGImageDestinationAddImage(destination, image, nil);
                if CGImageDestinationFinalize(destination) {
                    exit(0)

import Foundation
import Cocoa

func generateQRImageFromString(string: String, errorCorrection: String, sideLength: CGFloat) -> CGImage?
{
    let data = string.dataUsingEncoding( NSISOLatin1StringEncoding)
    let filter = CIFilter(name:"CIQRCodeGenerator")
