Measurement of the average lifetime ofB hadrons