Refactoring of write VECSXP

* src/rmatio.c: Several changes to make the write of VECSXP more
  general. Improved support to write more complicated list structures.

* inst/tests/test_rmatio.r: Added several test cases.