Error while unpartitioning hard drive?
Boot from Recovery (hold Command ⌘+R on startup), open Disk Utility and retry your partition deletion operation.

Side note, for partitions on the boot drive, it's usually best (if not required) to use Recovery.

EDIT:

To remove the 24.22 GB Ubuntu partition, try the following command after unlocking the CoreStorage group with diskutil cs unlockVolume (backups are always recommended):

diskutil cs revert 32D2E33F-8D67-4B7F-8CF5-ADFCB1C01C74


In theory, the above command should revert the partition "Macintosh HD" to a regular partition (sans CoreStorage and encryption). Then:

diskutil eraseVolume /dev/disk0s4


should remove the Ubuntu partition.

To merge the partitions, open Disk Utility from Recovery, select the ex-Ubuntu partition and click - underneath the pie chart. This should remove the ex-Ubuntu partition and merge it with your Macintosh HD primary partition.