YAML encoder fix for 3.0 serializers.

Closes #2283.