We need to encode the payload since rcon is a binary protocol. Also, add some more error checking. Fixes #1605.