py2.6 compat

Closes #579. Ready for review & merge @luizirber @ctb @camillescott