Three-Dimensional Simulation of Molecular Cloud Formation