Modeling and design of an X-band rf photoinjector