Extensions of representations and cohomology