Support automatic packet resize when flushing a stream

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>