The Hodge filtration on nonabelian cohomology