Fix possible crash when setting bg image