THRIFT-3515 Python 2.6 compatibility and test on CI

This closes #766
diff --git a/lib/py/src/compat.py b/lib/py/src/compat.py
index b2f47dc..06f672a 100644
--- a/lib/py/src/compat.py
+++ b/lib/py/src/compat.py
@@ -22,6 +22,6 @@
 
   def str_to_binary(str_val):
     try:
-      return bytearray(str_val, 'utf8')
+      return bytes(str_val, 'utf8')
     except:
       return str_val
diff --git a/lib/py/src/protocol/TCompactProtocol.py b/lib/py/src/protocol/TCompactProtocol.py
index a8b025a..6023066 100644
--- a/lib/py/src/protocol/TCompactProtocol.py
+++ b/lib/py/src/protocol/TCompactProtocol.py
@@ -56,7 +56,7 @@
 
 
 def writeVarint(trans, n):
-  out = []
+  out = bytearray()
   while True:
     if n & ~0x7f == 0:
       out.append(n)
@@ -64,7 +64,7 @@
     else:
       out.append((n & 0xff) | 0x80)
       n = n >> 7
-  trans.write(bytearray(out))
+  trans.write(bytes(out))
 
 
 def readVarint(trans):
diff --git a/lib/py/src/protocol/TJSONProtocol.py b/lib/py/src/protocol/TJSONProtocol.py
index acfce4a..3612e91 100644
--- a/lib/py/src/protocol/TJSONProtocol.py
+++ b/lib/py/src/protocol/TJSONProtocol.py
@@ -203,7 +203,7 @@
     json_str.append('"')
     self.trans.write(str_to_binary(''.join(json_str)))
 
-  def writeJSONNumber(self, number, formatter='{}'):
+  def writeJSONNumber(self, number, formatter='{0}'):
     self.context.write()
     jsNumber = str(formatter.format(number)).encode('ascii')
     if self.context.escapeNum():
@@ -550,7 +550,7 @@
 
   def writeDouble(self, dbl):
     # 17 significant digits should be just enough for any double precision value.
-    self.writeJSONNumber(dbl, '{:.17g}')
+    self.writeJSONNumber(dbl, '{0:.17g}')
 
   def writeString(self, string):
     self.writeJSONString(string)