When adding another view controller’s view as a subview, you should implement the custom container calls, addChildViewController and didMoveToParentViewController. BTW, the eliminates your need to maintain your own strong reference to that view controller.
Fix a few leaks and perform casting to avoid warning
Free second buffer, too
Set glClearColor to 0,0,0,0; use kCGImageAlphaPremultipliedLast for CGBitmapInfo when creating image; eliminate CGImageCreateWithMaskingColors
Merge pull request #1 from robertmryan/master

Different technique for creating CGImageRef fixes problem with UIImagePNGRepresentation issue