Properly encode the payload