Base 64 implementation in Javascript