Use UIGraphics* functions to resize image because it seems more stable than the CGContext based one.