Added ply write function.