Cognitive radio networks with cooperative transmission could effectively improve the spectrum efficiency and data rate. Under this network scenario, based on the sensing results and the channel quality on all channels, there are three possible transmission modes: direct transmission, multi-hop transmission and cooperative transmission. To optimize the system performance, three issues should be carefully considered: whether or not and which relay is needed, which channel is selected, and which transmission mode is used. Therefore, in this paper, we solve these three problems jointly to optimize the outage capacity for cognitive radio networks with cooperative transmission. Specifically, we emphasize on the imperfect channel sensing condition. We formulate the optimization problem as a discrete optimization problem. Then an efficient algorithm based on a discrete stochastic optimization algorithm is proposed to maximize the outage capacity to determine the relay and select the optimal channel and transmission mode. Simulation results are presented to demonstrate the performance of the proposed scheme.