Add url safe base64 encoding

BC safe with fallback to the old way of encoding
wow, this is a very good trick!