Quasiconformal mappings and sharp estimates for the distance to L^\infty in some function spaces