Refactored base64 encoding code
Added base64url encoding

closes #6