Use correct Base64 encoder, depending on availability

Fixes the issue noted in #109
I haven't properly tested this in Node, but I believe the approach is correct.