Encode base-64 strings with JavaScript