Update to work with Python 3/Sublime Text 3

Updates the file for Python 3, so it runs with Sublime Text 3.

Not sure whether there is a better way than explicitly converting all_before and all_after to lists ...!? But that works.