avconv: factor flushing encoders out of output_packet().