Fixed bug in decoder that didn't return frames on flush; improved encoder to not crash when flushing after no frames processed