The main write loop is refactored so that adding further formats via the new Encoder interface should be much simpler.