On the basis of a home-made femtosecond Yb-doped fiber laser, we designed a compact and efficient third harmonic generation scheme by a simple compensation plate of β-BaB2O4 crystal. The compensation plate is optimized through its thickness and cutting angle to reverse both spatial and temporal walk-off. By optimizing the parameters of the compensation plate and incident light intensity, a maximum output of 2.23 W with a repetition rate of 1 MHz at 345 nm is obtained, which implies a conversion efficiency of 23% from the infrared to ultraviolet.