add todict() to convert to a python dictionary