For the best results, follow these steps when exporting from FCPX:
File > Share > Master File…
Go into "Settings"
Set Format to "Computer".
Set Video Codec to H.264 (either Better Quality or Faster Encode, depending on how long you want to wait. Quality difference is minor.)
Set Resolution to the same as the source video (usually 1920 x 1080)
Check 'Include chapter markers' (for a future feature, not currently supported)
Choose where you want to save it, then click 'Save'
Alternatively, you can use Compressor or Handbrake to fine tune the bitrate and other settings.