fix attribute value encoding

Attribute values need to be encoded in the output, since they are
decoded by the parser.  Without this, attribute values can be
constructed to include pretty much anything in the output.