python2.6 compatibility related.

in py2.6 datetime.timedelta doesn't have total_seconds method.
base64.urlsafe_b64encode doesn't work with bytearray