Synthesizing arbitrary quantum states in a superconducting resonator