[core] Better unicode handling on message sending

This commits makes sure that even if a module sent us bytes, or a str
that came out of .encode(), we will always send it properly and never fail
on various AttributeError exceptions (bytes don't have .encode()) or
UnicodeDecoteError exceptions.