Improved cosmological constraints from a Bayesian hierarchical model of supernova type Ia data