Make sure all inputs are Unicode in a safe way

Check if the input message is a str (not unicode), and decode it if so.
This makes UTF-8 mode work seamlessly in all use cases.