Fix crashes when no display is connected at startup

Under such conditions, we were dereferencing a NULL last_good_mode
pointer, and also dereferencing a NULL encoder.