use encodebytes instead of encodestring (#2483)

Pull request for the Issue: #2483