Found this way to take an image of just the partitions and not the empty space at the end of the disk:
Run "fdisk -l" on the device.
Make sure the units are set to sectors (they are by default in recent versions of fdisk)
Read the end sector of the last partition.
Add 1
Divide by 2048 to convert to megabytes
Round up to the nearest whole number (better to copy an unneeded sector than not copy sectors that are needed)
dd if=/dev/sdX of=filename.img bs=1M count=<size in MB>