Add Ruby 2.0 support for build scripts

Switch to OptionParser from GetoptLong/RDoc::usage, which has been removed in ruby 2.0.
Conform to new behavior in IO Class.
Update shebangs.