Would it be possible to have several bitmasks in one tileset? I don't have a complete tileset for all possible placements, so some tiles would need to be used with several arrangements.
For example:
This tile would need to be used when there are even more tiles around it than seen it the bitmask.