Tom Brady agrees to extension with Patriots, gives team salary cap flexibility