             imageType = kUTTypeGIF
             
         default:
-            imageType = kUTTypePNG
-            fileExtension = "png"
+            type = "png"
         }
-    } else {
-        imageType = kUTTypePNG
-        fileExtension = "png"
+        
+        fileExtension = type
     }
     
     var errorCorrection = "M"
     if let correction = userDefaults.stringForKey("e") {
-        if contains(["L", "M", "Q", "H"], correction) {
+        if contains(["L", "Q", "H"], correction) {
             errorCorrection = correction
         }
     }

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

    let image = filter.outputImage
    
    let extent = CGRectIntegral(image.extent())
    let scale = sideLength / CGRectGetWidth(extent)
    let sideLengthUInt = UInt(sideLength)
    let colorspace = CGColorSpaceCreateDeviceGray()
    let alphaMask = CGBitmapInfo(rawValue:CGImageAlphaInfo.None.rawValue)
    let bitmapRef = CGBitmapContextCreate(nil, sideLengthUInt, sideLengthUInt, 8, 4 * sideLengthUInt, colorspace, alphaMask)
    let context = CIContext(CGContext:bitmapRef, options:nil)
    
    let bitmapImage = context.createCGImage(image, fromRect:extent)
