Backport RCFile-related patches for better compatibility with CDH 4.1.2

Back-porting some RCFile-related patches (modified signature, some resource leak fixes, performance improvements, etc.) for better compatibility with CDH 4.1.2.