MAHOUT-1500: combine serializeMatrix and serializeVector into single method

Signed-off-by: Anand Avati <avati@redhat.com>