changed im_self to __self__ for python3 compatibility