[1.6.x] Fixed #21355 -- try importing _imaging from PIL namespace first.

Backport of 5725236c3e from master
[1.6.x] Fixed #21448 -- Fixed test client logout with cookie-based sessions

Thanks Gunnar Scherf for the report and the suggested patch.
Backport of 384816fcc from master.