Fix potential output buffer overflow in encoder.