UIGraphicsBeginImageContextWithOptions(CGSizeMake(400, 400), NO, 1);
Setting this argument to NO solves my problem.