In this paper, we present a three-dimensional quasistatic model for high brightness beam dynamics simulation in rf/dc photoinjectors, rf linacs, and similar devices on parallel computers. In this model, electrostatic space-charge forces within a charged particle beam are calculated self-consistently at each time step by solving the three-dimensional Poisson equation in the beam frame and then transforming back to the laboratory frame. When the beam has a large energy spread, it is divided into a number of energy bins or slices so that the space-charge forces are calculated from the contribution of each bin and summed together. Image-charge effects from conducting photocathode are also included efficiently using a shifted-Green function method. For a beam with large aspect ratio, e.g., during emission, an integrated Green function method is used to solve the three-dimensional Poisson equation. Using this model, we studied beam transport in one Linac Coherent Light Sources photoinjector design through the first traveling wave linac with initial misalignment with respect to the accelerating axis