                 let blue = dataType[offset+3]
                 
                 let avg = (UInt32(red) + UInt32(green) + UInt32(blue))/3
-
+                
                 dataType[offset + 1] = UInt8(avg)
                 dataType[offset + 2] = UInt8(avg)
                 dataType[offset + 3] = UInt8(avg)

        
        // Allocate memory for image data. This is the destination in memory
        // where any drawing to the bitmap context will be rendered.
        let bitmapData = malloc(CUnsignedLong(bitmapByteCount))
        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue)
        
        // Create the bitmap context. We want pre-multiplied ARGB, 8-bits
        // per component. Regardless of what the source image format is
        // (CMYK, Grayscale, and so on) it will be converted over to the format
        // specified here by CGBitmapContextCreate.
        let context = CGBitmapContextCreate(bitmapData, pixelsWide, pixelsHigh, CUnsignedLong(8), CUnsignedLong(bitmapBytesPerRow), colorSpace, bitmapInfo)
        
        return context
    }

        // Now we can get a pointer to the image data associated with the bitmap
        // context.
        
        
        var data = CGBitmapContextGetData(context)
        var dataType = UnsafeMutablePointer<UInt8>(data)
        let point: CGPoint = CGPointMake(0, 0)
        
        for var x = 0; x < Int(pixelsWide) ; x++ {
            for var y = 0; y < Int(pixelsHigh) ; y++ {
                let offset = 4*((Int(pixelsWide) * Int(y)) + Int(x))
