Improve encode performance

Yeah so the continue; statements look rather weird. I did that for the
comments before the if statements, but I can change that if preferred.

Signed-off-by: Eli Skeggs <eskeggs@globesherpa.com>