Generation of nonclassical photon states using a superconducting qubit in a microcavity