JWT Encoding from scratch