Improve media types

A media type has an optional charset, which needs to be
appended to the text representation. There is also a default
type 'application/octet-stream', which is used whenever
nothing else matches.