Automatically use background thread for screenshots.

If we try to take a screenshot outside of the display thread, we
segfault. This ensures that can't happen.

Fixes #329.