tests: improved screenshot test to get tempdir using tempfile module.