Compatibility with python 3

Fixed problems with the encryption of messages due to differences
between bytes and strings.