Python 3 compatibility changes

- Change import statements to from .x import y

- Change dict.iteritems() to dict.items()

- Use integer division in diagnostics 

- Force values to list in cases of dict.values() or map(f, list) or
filter(f, list)

- Change xrange to range and use list(range) when code expects indices.

- All tests pass on Windows/Linux Python 3.3.2

- Additional minor pep8 changes throughout. 

- I don't have Python 2.x installed so can't test changes there. The only things that I think might be an issue are the changes to // instead of / and in Python 3 os.path.walk was moved to just os.walk.

(I've never done a pull request before and am new overall to contributing. Let me know if I need to change something or include more details)