fix bug when null is passed to encode methods.