make sure out is C_CONTIGUOUS