Add spec for yaml dumping StringIO
Fix YAML dumping for StringIO

Fixes #2425