Fix and format code example in README
Fix errors and warnings pointed out by Eclipse PyDev code analysis

Mostly unused imports and variables, non-standard indentation.
Some real errors.
Should be clear what the problem was from the diff.