Fix encode! to pass tests of D.3