We outline a new control system model for the distributed dynamics of compressible gas flow through large-scale pipeline networks with time-varying injections, withdrawals, and control actions of compressors and regulators. The gas dynamics PDE equations over the pipelines, together with boundary conditions at junctions, are reduced using lumped elements to a sparse nonlinear ODE system expressed in vector-matrix form using graph theoretic notation. This system, which we call the reduced network flow (RNF) model, is a consistent discretization of the PDE equations for gas flow. The RNF forms the dynamic constraints for optimal control problems for pipeline systems with known time-varying withdrawals and injections and gas pressure limits throughout the network. The objectives include economic transient compression (ETC) and minimum load shedding (MLS), which involve minimizing compression costs or, if that is infeasible, minimizing the unfulfilled deliveries, respectively. These continuous functional optimization problems are approximated using the Legendre-Gauss-Lobatto (LGL) pseudospectral collocation scheme to yield a family of nonlinear programs, whose solutions approach the optima with finer discretization. Simulation and optimization of time-varying scenarios on an example natural gas transmission network demonstrate the gains in security and efficiency over methods that assume steady-state behavior.