Add explicit X11 threads initialization

See https://bugs.freedesktop.org/show_bug.cgi?id=82630

It would certainly be better to avoid X11 calls from separate threads
alltogether, and to my best knowledge, I do that in the main
application. But something in the backends seem to use gtk_* calls as
well, and I haven't even been able to tell where and which one so far.
(I suspect cairo.) Fixing this in another way and reverting this is a
TODO.
Poppler upstream update 0.26.5 will fix poppler bug #82630 and allow us to use poppler_document_new_from_stream()
pixbuf backend: Check if the pixbuf is actually valid
Workaround for GTK bug #736624
Check if created image surfaces are valid before using them

This is related to 9662bf3. This commit also includes a mechanism to
fall back to rendering directly to the window if creating the temporary
image surface fails.