     }
 
     private func pixelGridForImage(image: UIImage) -> BlockGrid {
-        var imageRef = image.CGImage!
-        var width = CGImageGetWidth(imageRef)
-        var height = CGImageGetHeight(imageRef)
-        var colorSpace = CGColorSpaceCreateDeviceRGB()
-        var rawData = UnsafeMutablePointer<UInt8>(malloc(height * width * 4))
-        var bytesPerPixel = 4
-        var bytesPerRow = bytesPerPixel * width
-        var bitsPerComponent = 8
+        let imageRef = image.CGImage!
+        let width = CGImageGetWidth(imageRef)
+        let height = CGImageGetHeight(imageRef)
+        let colorSpace = CGColorSpaceCreateDeviceRGB()
+        let rawData = UnsafeMutablePointer<UInt8>(malloc(height * width * 4))
+        let bytesPerPixel = 4
+        let bytesPerRow = bytesPerPixel * width
+        let bitsPerComponent = 8
 
         let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue | CGBitmapInfo.ByteOrder32Big.rawValue)
-        var context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue)
+        let context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue)
         CGContextDrawImage(context, CGRect(x: 0, y: 0, width: width, height: height), imageRef)
-        var grid = BlockGrid(width: width, height: height)
+        let grid = BlockGrid(width: width, height: height)
         for row in 0..<height {
             for col in 0..<width {
-                var byteIndex = (bytesPerRow * row) + col * bytesPerPixel
+                let byteIndex = (bytesPerRow * row) + col * bytesPerPixel
                 let r = Double(rawData[byteIndex]) / 255.0
                 let g = Double(rawData[byteIndex + 1]) / 255.0
                 let b = Double(rawData[byteIndex + 2]) / 255.0

            CGContextClearRect(ctx, ctxRect)
        }

        var blockWidth = input.size.width / CGFloat(pixelGrid.width)
        var blockHeight = input.size.height / CGFloat(pixelGrid.height)
        var attributes = [NSFontAttributeName: font, NSForegroundColorAttributeName: UIColor.blackColor()]
        for row in 0..<pixelGrid.height {
            for col in 0..<pixelGrid.width {
                var block = pixelGrid.block(atRow: row, column: col)
                var luminance = self.luminance(block)
                var ASCIIResult = definition.stringForLuminance(Double(luminance))!
                var rect = CGRect(x: blockWidth * CGFloat(col), y: blockHeight * CGFloat(row), width: blockWidth, height: blockHeight)

                if colorMode == .Color {
                    let color = UIColor(red: CGFloat(block.r), green: CGFloat(block.g), blue: CGFloat(block.b), alpha: 1.0)

        if scaleFactor > min(image.size.height, image.size.width) {
            scaleFactor = min(image.size.height, image.size.width)
        }
        let ratio = scaleFactor / image.size.width
        let newWidth = scaleFactor
        let newHeight = ratio * image.size.height
        let size = CGSize(width: newWidth, height: newHeight)
        UIGraphicsBeginImageContextWithOptions(size, true, 1.0)
        image.drawInRect(CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
        let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return scaledImage
    }
