Cached entire energy row at once for cost calculations.
Switched to list for seam and byte array for energy row conversions.
Switched grayscale creation to use scipy.fromimage.