python2.6 compatibility related.
in py2.6 datetime.timedelta doesnt have total_seconds method.
base64.urlsafe_b64encode doesnt work with bytearray