Covariant quantization of chiral bosons and anomaly cancellation