Optimizing information flow in biological networks