You will want to use get_the_terms( $post->ID, 'custom_taxonomy' )
instead of the_terms()
This will return an array of term objects. You can access the term names by doing the following:
while ( $my_query->have_posts() ) : $my_query->the_post();
$custom_taxonomy = the_terms( $post->ID, 'custom_taxonomy');
endwhile;
// Print the term names
foreach ( $custom_taxonomy as $term ) {
echo $term->name;
}
Check out the codex for more information on get_the_terms()