Adds MQTTMessage class method to encode strings