Make it compatible with Python 2

I think it's more convenient if gin supports both Python 2 and 3, so I send this pull request. It's your call.

Anyway, gin is good, I have used it many times these days. Thanks.