We analyze the ergodic capacity and capacity bound of a multiple-input-multiple-output (MIMO) orthogonal frequency-division multiplexing (OFDM) system suffering from frequency-selective in-phase and quadrature-phase (IQ) imbalances along with residual carrier frequency offset (CFO). In the literature, capacity analysis of systems with IQ imbalance has been done only for the single antenna case and has considered either frequency-flat IQ imbalances at both transmitter and receiver sides without CFO or only receiver-side IQ imbalances with CFO. Additionally, these works dealt with IQ imbalance by treating the mirror tone interference as an additional source of noise, which is not optimal. In this paper, we consider a generalized system model that includes a multi-antenna system with frequency-selective IQ imbalances at both the transmitter and the receiver sides, in addition to the presence of CFO, and perform capacity analysis considering joint detection of the signal and its self-interference. In addition, for the imperfect channel estimation case, existing works in the literature optimize for pilot spacings and pilot designs. Pilot-data power allocation is an additional degree of freedom that is available to further optimize the system and has not been addressed before. Therefore, we analyze the pilot-data power allocation that maximizes the capacity bound and obtain a closed-form solution for the optimal power allocation at high signal-to-noise ratio (SNR) regime. We then study how the IQ imbalance and residual CFO severity affect capacity, symbol error rate (SER), and capacity bound maximizing power allocation. Finally, we derive the optimal power allocation when the channel is slow varying and remains constant over a block of several OFDM symbols. The derived results are validated through Monte Carlo simulations.