Initialize GError pointers to NULL
Clean up some GError-related code
Set empty output if the command fails

There's a NULL dereference later if this doesn't happen.
Guard against NULL in DOWNLOAD_ERROR

If there's an error before the destination has been decided, it's NULL.
This can happen if the download URL is too long for a shell command and
you use spawn_sync.