Add base64 and file output depending on the mode