Fix for line toObject method.

Calculate line points when we need to serialize it.

Fix #1396 #744