Use glib functions for base64 decoding/encoding
This fixes several coverity warnings about 'tainted data index sink' and a fixme about thread safety in the old base64_decode implementation.
Had to adapt the code that used base64_encode_real: