Ensure base64 is valid before decoding

Valid base64 is a multiple of 4 bytes, so if we don't have that,
pad it with '='.  This method fails if we use wide characters in
shortcodes, but if we do that, all is lost anyway