added to_h function to task context

It has been present in the webbapp branch, but got lost when it was merged to master