You are asking a lot of a computer to do it all at once. Split the job into two passes.
Export to a high bitrate professional codec first (ProRes or Cineform perhaps). Then convert that using Handbrake or similar to an h264 complaint file.
3 hours for a 30 minute video however isn't too bad. There's lots of work involved in converting between codecs, and reexporting an encoded file.