Add decode, encode and encodeToString convenience functions.