             else{
                 memcpy(&rawData, imageBuffer.contents(), imageBuffer.length)
             }
-
+            
             let cgprovider = CGDataProviderCreateWithData(nil, &rawData, imageByteCount, nil)
             
             if texture.pixelFormat == .RGBA16Unorm {

            else {
                t.replaceRegion(region, mipmapLevel:0, withBytes:rawData, bytesPerRow:componentsPerRow)
            }
        }        
        return texture
    }
}

            let imageByteCount  = bytesPerRow * height
            
            let imageBuffer = provider.context.device.newBufferWithLength( imageByteCount, options: MTLResourceOptions.CPUCacheModeDefaultCache)
            
            //
            // Currently, OSX does not have work version of texture.getBytes version.
            // Use blit encoder to copy data from device memory
            //
            provider.context.execute({ (commandBuffer) -> Void in
                
                let blitEncoder = commandBuffer.blitCommandEncoder()
                
                blitEncoder.copyFromTexture(texture,
