UIGraphicsBeginImageContext
will create a context with a scale of 1.0, or non-retina. But you most likely want to create a context that matches the scale of your device. Use the new UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale)
function.
Replace
UIGraphicsBeginImageContext(CGSizeMake(320.0, 164));
with
UIGraphicsBeginImageContextWithOptions(CGSizeMake(320.0, 164), YES, 0.0);
0.0 as scale parameter means "use device main screen scale". If your image has transparency you want to use NO as second parameter.