Following changes are made with minimal touches;
- version dependent module imports
- codecs.open instead of open (for encoding errors)
- string_is_ascii modified for better compatibility
- In create_messages.py, synonym_defs are sorted as well to increase
testability, as Python 3 does not guarantee key order.
Note that this will cause previously generated files to have different
orders from the files generated without this patch.
- small changes; paranthesis around "print"s, has_key -> in,
"except x, y" -> "except x as y", sorted -> sort
Other files need similar small changes but are not touched as they are not
referenced from build.py
Fixes https://github.com/google/blockly/issues/2112