use sc save instead of save in the map editor. This will create a file per layer. For each layer, load that as a dat: file into an array then pass that array to bgload. If you have custom tiles load that as grp5:filename.