The name of ToStringCoder class  is confusing, since the output of encode() on Python3 will be bytes. On Python 2 the output is also bytes, since bytes and string are synonyms on Py2.
ToBytesCoder would be a better name for this class.
Note that this class is not listed in coders that constitute Public APIs , so we can treat this as internal change. As a courtesy to users who happened to reference a non-public coder in their pipelines we can keep the old class name as an alias, e.g. ToStringCoder = ToBytesCoder to avoid friction, but clean up Beam codeabase to use the new name.