Add url safe base64 encoding

BC safe with fallback to the old way of encoding