add python3 compatibility
changes come from rebecca@caktusgroup.com