OmeroWeb flake8 cleanup of most severe warnings (dev_5_0)

I've started to review flake8 warnings for omeroweb and will submit changes over time to try and not interfere with other pull requests.

The changes in this PR attempt to fix the most severe flake8 warnings and should be reviewed most carefully.

--rebased-from #2216