avcodec/mjpegenc: use av_freep(), avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>