refactor bytemasking into base64 function