Do a bunch of cleanup in contrib/

This change does a bunch of cleanup that we've done in review board but
neglected to do here, including:
- Unicode string migration
- Print function migration
- Remove selenium crud
- Make sure all commands run their code from an "if __name__ == '__main__"
  block.
- General import maintenance and cleanup
- Pull in "input" from six.moves
- Make the extension generator create code with the above improvements

Testing done:
- Verified common scripts still did their thing
- Generated an extension and checked the output

Reviewed at https://reviews.reviewboard.org/r/4977/