[FEAT] Modify the code to be Python 3 compatible

- Use UnicodeMixin instead of a separate __str__ method
- Replace __cmp__ with _cmpkey and ComparableMixin
- Use bytes.decode instead of unicode(,)
- Use BytesIO instead of StringIO if it's binary data
- Open binary files in binary mode
- Only decode/encode std* in Py2
- Always have no 'space' before \n in json strings (< Py3.4)
- Map basestring to (str,) in scripts (in Py3)
- Map xrange to range in casechecker (in Py3)
- Use future print_function if necessary
- Decode password file as UTF8

Change-Id: Ia7d416a578cc0fb52eaf1e2426244a693395738a
Merge "[FEAT] Modify the code to be Python 3 compatible"