Superconducting pairing and density-wave instabilities in quasi-one-dimensional conductors