Update encode and decode functions to use base64