fixed memory leaks

Hey man, I dug a little deeper and found a couple of possible memory leaks, and one definite one (stopped my app crashing once I changed it). The issue seemed to be that you were allocating the frame, then re-allocating the same pointer as a picture in convert_image. 

Anyway, works for me, but it's not particularly tested. Might be a slight performance improvement too?