modifed jpeg encoder convenience function to use av_packet.