ec2 module: add backward-compatible support for Python 3.3+

This PR is based on the vpc-py3 branch (#2399), so please merge that one first, thanks :)

All tests passed.