use rb_ary_entry() and rb_ary_subseq() instead of RARRAY_PTR

* Based on a patch by Dirkjan Bussink
* See MRI Bug #8399: https://bugs.ruby-lang.org/issues/8399
Merge pull request #26 from eregon/1-4-stable

use rb_ary_entry() and rb_ary_subseq() instead of RARRAY_PTR