Prevent Errno::EFILENAMETOOLONG when creating tempfile

Use Digest::MD5.hexdigest to change the name of the tempfile being generated.  This should also remove the need to check for illegal filename characters.