YAML encoder fix for 3.0 serializers.
Merge pull request #2315 from tomchristie/yaml-encoder-fix

YAML encoder fix for 3.0 serializers.