Your approach is perfectly fine:.
Here's a C example that embeds catcat, copiesand upon execution, writes it to a tempfile, and marks it executable:
//$ xxd --include /bin/cat
//^ create _bin_cat and _bin_cat_len
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
int main(){
//TODO: error checking everywhere
char tmp[] = "/tmp/cat-XXXXXX";
mkstemp(tmp);
FILE* f = fopen(tmp, "w");
fwrite(_bin_cat, _bin_cat_len, 1, f);
fchmod(fileno(f), 0700);
puts(tmp); //print the name of where the embeded cat got copied to
return 0;
}
Works fine for me.