We analyze the performance of dual-hop two-way amplify-and-forward relaying in the presence of in-phase and quadrature-phase imbalance (IQI) at the relay node. In particular, two power allocation schemes, namely, fixed power allocation and instantaneous power allocation, are proposed to improve the system reliability and robustness against IQI under a total transmit power constraint. For each proposed scheme, the outage probability is investigated over independent, non-identically distributed Nakagami- m fading channels, and exact closed-form expressions and bounds are derived. Our theoretical analysis indicates that, without IQI compensation, IQI can create fundamental performance limits on two-way relaying. However, these limits can be avoided by performing IQI compensation at source nodes. Compared with the equal power allocation scheme, our numerical results show that the two proposed power allocation schemes can significantly improve the outage performance, thus reducing the IQI effects, particularly when the total power budget is large.